<?php
namespace app\admin\command;

use app\common\model\auth\AdminModel;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;

class CreateAdminCommand extends Command
{
    protected function configure()
    {
        $this->setName('create-admin')
        	// ->addArgument('name', Argument::OPTIONAL, "your name")
            // ->addOption('city', null, Option::VALUE_REQUIRED, 'city name')
        	->setDescription('Say Hello');
    }

    protected function execute(Input $input, Output $output)
    {
    	// $name = trim($input->getArgument('name'));
      	// $name = $name ?: 'thinkphp';

		// if ($input->hasOption('city')) {
        // 	$city = PHP_EOL . 'From ' . $input->getOption('city');
        // } else {
        // 	$city = '';
        // }
        $salt = mt_rand(1000,9999);
        AdminModel::create([
            'account' => 'admin',
            'password' => encrypt_password(123456,$salt),
            'salt' => $salt
        ]);
        
        $output->writeln("create admin user success!");
    }
}